{{!

  Copyright (c) Facebook, Inc. and its affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}{{!

Included from CythonServices.pyx, it defines a Python wrapper for each type
of C++ promise that needs to be returned to C++. Cython doesn't support
templating on Python classes. This file is necessary primarily because the
cPromise shared_ptr needs to point to a promise that wraps a specific return
type in C++. The Python wrapper then gets passed into a coroutine where the
promise can have it's value set after the handler coroutine has finished
executing.

}}

cdef extern from "<utility>" namespace "std":
{{#program:unique_functions_by_return_type}}
{{#function:returnType}}
    cdef cFollyPromise[{{!
            }}{{> services/CythonReturnTypeCppType}}{{!
        }}] move_promise_{{> types/CythonCppTypeIdent}} "std::move"(
        cFollyPromise[{{!
            }}{{> services/CythonReturnTypeCppType}}{{!
        }}])
{{/function:returnType}}
{{/program:unique_functions_by_return_type}}
{{^program:unique_functions_by_return_type}}
    pass
{{/program:unique_functions_by_return_type}}
{{#program:unique_functions_by_return_type}}
{{#function:returnType}}

@cython.auto_pickle(False)
cdef class Promise_{{> types/CythonCppTypeIdent}}:
    cdef cFollyPromise[{{!
            }}{{> services/CythonReturnTypeCppType}}{{!
        }}] cPromise

    @staticmethod
    cdef create(cFollyPromise[{{!
            }}{{> services/CythonReturnTypeCppType}}{{!
        }}] cPromise):
        inst = <Promise_{{> types/CythonCppTypeIdent}}>{{!
        }}Promise_{{> types/CythonCppTypeIdent}}.__new__({{!
        }}Promise_{{> types/CythonCppTypeIdent}})
        inst.cPromise = move_promise_{{> types/CythonCppTypeIdent}}(cPromise)
        return inst
{{/function:returnType}}
{{/program:unique_functions_by_return_type}}
